<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">公众号关注统计</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         ajax="false"
                                         rendered="#{wechatAccountBean.isNormal()}"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         rendered="#{registrationStatBean.isNormal() }"
                                         ajax="false">
                            <p:dataExporter type="xls" target="statBeanDataTable" fileName="export"/>
                        </p:commandButton>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{wechatAccountBean.onRest}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{wechatAccountBean.isNormal()}"/>


                    </f:facet>
                </p:toolbar>
            </div>

            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;">

                                <p:outputLabel for="startDate" value="时间"/>
                                <p:calendar id="startDate" value="#{wechatAccountBean.$.startDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"
                                            readonlyInput="true"/>—
                                <p:calendar id="endDate" value="#{wechatAccountBean.$.endDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"
                                            readonlyInput="true"/>

                                <p:outputLabel for="productId" value="产品"/>
                                <p:selectOneMenu id="productId" value="#{wechatAccountBean.$.productId}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{wechatAccountBean.commProductIds}"
                                            var="product"
                                            itemLabel="#{product.name}" itemValue="#{product.productId}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="activityId" value="活动id"/>
                                <p:inputText id="activityId" value="#{wechatAccountBean.$.activityId}"/>

                                <p:outputLabel for="channelId" value="渠道"/>
                                <p:selectOneMenu id="channelId" value="#{wechatAccountBean.$.channelId}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{wechatAccountBean.commProductChannels}"
                                            var="channel"
                                            itemLabel="#{channel.channelName}" itemValue="#{channel.channelCode}"/>
                                </p:selectOneMenu>

                            </p:panelGrid>

                        </div>
                        <div class="card">
                            <p:dataTable id="statBeanDataTable"
                                         style="width: 100%"
                                         var="statBean"
                                         value="#{wechatAccountBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="97%"
                                         reflow="true"
                                         resizableColumns="true">

                                <p:column headerText="日期" >
                                    <h:outputText value="#{statBean.dateTime}"/>
                                </p:column>
                                <p:column headerText="产品">
                                    <h:outputText value="#{statBean.productId}"/>
                                </p:column>
                                <p:column headerText="渠道">
                                    <h:outputText value="#{statBean.channelId}"/>
                                </p:column>
                                <p:column headerText="活动id">
                                    <h:outputText value="#{statBean.activityId}"/>
                                </p:column>
                                <p:column headerText="模板id">
                                    <h:outputText value="#{statBean.templateId}"/>
                                </p:column>
                                <p:column headerText="H5-访问外推页面uv">
                                    <h:outputText value="#{statBean.pageUv}"/>
                                </p:column>
                                <p:column headerText="H5-关注公众号人数">
                                    <h:outputText value="#{statBean.attentionNum}" />
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
